import {defineComponent, Fragment} from "vue";
import auth from "@/utils/auth";

export default defineComponent({
    name: "Power",
    props: {
        value: {
            type: undefined, default: [],
        }
    },
    setup(props, {slots}) {
        return () => {
            if (!slots) return null;
            if (!props.value) return (<Fragment>{slots.default?.()}</Fragment>);
            if (Array.isArray(props.value)) {
                return auth.hasAnyPower(props.value) ? (<Fragment>{slots.default?.()}</Fragment>) : null;
            } else {
                return auth.hasPower(props.value) ? (<Fragment>{slots.default?.()}</Fragment>) : null;
            }
        };
    }
});